//
//  HLTableViewController.m
//  YueYue
//
//  Created by hulu001 on 2023/5/17.
//

#import "HLTableViewController.h"

@interface HLTableViewController ()

@end

@implementation HLTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.kvoController = [FBKVOController controllerWithObserver:self];
}

- (void)initTableView
{
    [super initTableView];
    self.datasources = [NSMutableArray array];
    self.tableView.backgroundColor = UIColorWhite;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}

- (void)setupMJRefresh
{
    MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(headerRefresh)];
    [header setTitle:@"" forState:MJRefreshStateIdle];
    self.tableView.mj_header = header;
    
    MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(footerRefresh)];
    [footer setTitle:@"" forState:MJRefreshStateIdle];
    self.tableView.mj_footer = footer;
}


- (BOOL)shouldCustomizeNavigationBarTransitionIfHideable {
    return YES;
}

- (void)headerRefresh
{
    [self.request start];
}

- (void)footerRefresh
{
    [self.request start];
}

- (void)requestFinished:(__kindof YTKBaseRequest *)request
{
    [self endAnimateRefresh];
}

- (void)requestFailed:(__kindof YTKBaseRequest *)request
{
    [QMUITips showWithText:[request.error localizedDescription]];
    [self endAnimateRefresh];
    
}

- (void)noMordDataWithFooterRefresh
{
    [self.tableView.mj_footer endRefreshingWithNoMoreData];
}

- (void)endAnimateRefresh
{
    if ([self.tableView.mj_header isRefreshing]){
        [self.tableView.mj_header endRefreshing];
    }
    
    if ([self.tableView.mj_footer isRefreshing]){
        [self.tableView.mj_footer endRefreshing];
    }
}


@end
